package org.gruposp2p.dnie.client.ui.widget;

import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.CssResource;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;
import org.gruposp2p.dnie.client.util.URLConstants;

public class SignatureCounter extends Composite {

    private static SignatureCounterUiBinder uiBinder = GWT
                    .create(SignatureCounterUiBinder.class);

    interface SignatureCounterUiBinder extends 
            UiBinder<Widget, SignatureCounter> { }

    interface Style extends CssResource {
        String active();
        String notActive();
    }
	
    @UiField Style style;	
    @UiField HTML numberSignaturesField;
    @UiField HTML signLink;

    public SignatureCounter(
                String numberSignatures, boolean active, String jnlpUrl) {
        initWidget(uiBinder.createAndBindUi(this));
        numberSignaturesField.setHTML(numberSignatures);
        if (active) {
        	signLink.setHTML("<a href=\"" + jnlpUrl + "\">Firmar</a>");
        }
        if (!active) {
            signLink.removeStyleName(style.active());
            signLink.addStyleName(style.notActive());
            signLink.setText("Cerrado");
        }
    }

}